Understanding ECMAScript 6 by Nicholas C. Zakas
Author:Nicholas C. Zakas
Language: eng
Format: epub, mobi
Published: 2016-10-06T09:28:44+00:00
Delegating Generators
In some cases, combining the values from two iterators into one is useful. Generators can delegate to other generators using a special form of yield with a star (*) character. As with generator definitions, where the star appears doesn’t matter, as long as the star falls between the yield keyword and the generator function name. Here’s an example:
function *createNumberIterator() { yield 1; yield 2; } function *createColorIterator() { yield "red"; yield "green"; } function *createCombinedIterator() { yield *createNumberIterator(); yield *createColorIterator(); yield true; } var iterator = createCombinedIterator(); console.log(iterator.next()); // "{ value: 1, done: false }" console.log(iterator.next()); // "{ value: 2, done: false }" console.log(iterator.next()); // "{ value: "red", done: false }" console.log(iterator.next()); // "{ value: "green", done: false }" console.log(iterator.next()); // "{ value: true, done: false }" console.log(iterator.next()); // "{ value: undefined, done: true }"
Download
Understanding ECMAScript 6 by Nicholas C. Zakas.mobi
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Hello! Python by Anthony Briggs(10119)
The Mikado Method by Ola Ellnestam Daniel Brolund(10011)
Dependency Injection in .NET by Mark Seemann(9515)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7915)
Svelte with Test-Driven Development by Daniel Irvine(7790)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7767)
Test-Driven Development with PHP 8 by Rainier Sarabia(7526)
Layered Design for Ruby on Rails Applications by Dementyev Vladimir;(7357)
Web Development with Django by Ben Shaw Saurabh Badhwar(6862)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(6631)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6631)
React Application Architecture for Production by Alan Alickovic(6546)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5872)
Kotlin in Action by Dmitry Jemerov(5295)
Software Architecture for Web Developers by Mihaela Roxana Ghidersa(4786)
Audition by Ryu Murakami(4764)
Accelerating Server-Side Development with Fastify by Manuel Spigolon Maksim Sinik & Matteo Collina(4630)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4381)
Solidity Programming Essentials by Ritesh Modi(4359)
